package org.monster.context.servlet;

import javax.servlet.http.HttpServlet;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 服务者工厂
 *
 * @author Monster
 */
public class ServletFactory {

    /**
     * 日志器
     */
    private static final Logger logger = Logger.getLogger(ServletFactory.class
            .getName());
    /**
     * 类
     */
    private Class<?> clazz = null;

    /**
     * 获取实例
     *
     * @param clazz 类
     * @return 实例
     */
    public static HttpServlet getInstance(Class<?> clazz) {
        HttpServlet httpServlet = null;
        try {
            httpServlet = (HttpServlet) clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException ex) {
            logger.log(Level.SEVERE, null, ex);
        }
        return httpServlet;

    }

    /**
     * 获取类
     *
     * @return 类
     */
    public Class<?> getClazz() {
        return clazz;
    }

    /**
     * 设置类
     *
     * @param clazz 类
     */
    public void setClazz(Class<?> clazz) {
        this.clazz = clazz;
    }
}
